﻿

Namespace YahooManaged.Finance.Screener.StockCriterias

    ''' <summary>
    ''' Criteria definition for filtering results for specific stock exchange
    ''' </summary>
    ''' <remarks></remarks>
    Public Class ExchangeCriteria
        Inherits StockStringCriteriaDefinition

        Public Overrides ReadOnly Property DisplayName As String
            Get
                Return "Exchange Criteria"
            End Get
        End Property

        Public Overrides ReadOnly Property CriteriaName As String
            Get
                Return "Stock Exchange"
            End Get
        End Property

        Public Overrides ReadOnly Property CriteriaGroup As StockScreenerCriteriaGroup
            Get
                Return StockScreenerCriteriaGroup.Descriptive
            End Get
        End Property
        Public Overrides ReadOnly Property ProvidedQuoteProperties As QuoteProperty()
            Get
                Return {QuoteProperty.Symbol, _
                        QuoteProperty.Name, _
                        QuoteProperty.LastTradePriceOnly, _
                        QuoteProperty.LastTradeTime, _
                        QuoteProperty.MarketCapitalization}
            End Get
        End Property
        Public Overrides ReadOnly Property ProvidedScreenerProperties As StockScreenerProperty()
            Get
                Return {StockScreenerProperty.ReturnOnEquity, _
                        StockScreenerProperty.ReturnOnAssets, _
                        StockScreenerProperty.ForwardPriceToEarningsRatio}
            End Get
        End Property

        Friend Overrides ReadOnly Property IsValid As Boolean
            Get
                Return MyBase.IsValid AndAlso (MyBase.Value = "amex" Or MyBase.Value = "nasdaq" Or MyBase.Value = "nyse")
            End Get
        End Property

        Public Property Exchange As Nullable(Of StockExchange)
            Get
                If Me.IsValid Then
                    Select Case MyBase.Value
                        Case "amex" : Return StockExchange.AMEX
                        Case "nasdaq" : Return StockExchange.NASDAQ
                        Case "nyse" : Return StockExchange.NYSE
                        Case Else : Return Nothing
                    End Select
                Else
                    Return Nothing
                End If
            End Get
            Set(ByVal value As Nullable(Of StockExchange))
                If value.HasValue Then : MyBase.Value = value.ToString.ToLower
                Else : MyBase.Value = String.Empty
                End If
            End Set
        End Property

        Public Sub New()
            MyBase.new("a"c)
        End Sub

    End Class

    ''' <summary>
    ''' Criteria definition for filtering results for specific sector
    ''' </summary>
    ''' <remarks></remarks>
    Public Class SectorCriteria
        Inherits StockStringCriteriaDefinition

        Public Overrides ReadOnly Property DisplayName As String
            Get
                Return "Sector Criteria"
            End Get
        End Property

        Public Overrides ReadOnly Property CriteriaName As String
            Get
                Return "Sector"
            End Get
        End Property

        Public Overrides ReadOnly Property CriteriaGroup As StockScreenerCriteriaGroup
            Get
                Return StockScreenerCriteriaGroup.Descriptive
            End Get
        End Property
        Public Overrides ReadOnly Property ProvidedQuoteProperties As QuoteProperty()
            Get
                Return {QuoteProperty.Symbol, _
                        QuoteProperty.Name, _
                        QuoteProperty.LastTradePriceOnly, _
                        QuoteProperty.LastTradeTime, _
                        QuoteProperty.MarketCapitalization}
            End Get
        End Property
        Public Overrides ReadOnly Property ProvidedScreenerProperties As StockScreenerProperty()
            Get
                Return {StockScreenerProperty.ReturnOnEquity, _
                        StockScreenerProperty.ReturnOnAssets, _
                        StockScreenerProperty.ForwardPriceToEarningsRatio}
            End Get
        End Property

        Friend Overrides ReadOnly Property IsValid As Boolean
            Get
                Dim i As Integer = 0
                Return MyBase.IsValid AndAlso Integer.TryParse(MyBase.Value, i) AndAlso (i >= 1 And i <= 9)
            End Get
        End Property

        Public Property Sector As Nullable(Of Sector)
            Get
                If Me.IsValid Then : Return CType(CInt(MyBase.Value), Sector)
                Else : Return Nothing
                End If
            End Get
            Set(ByVal value As Nullable(Of Sector))
                If value.HasValue Then : MyBase.Value = CInt(value).ToString
                Else : MyBase.Value = String.Empty
                End If
            End Set
        End Property

        Public Sub New()
            MyBase.new("w"c)
        End Sub
    End Class

    ''' <summary>
    ''' Criteria definition for filtering results for specific industry
    ''' </summary>
    ''' <remarks></remarks>
    Public Class IndustryCriteria
        Inherits StockStringCriteriaDefinition

        Public Overrides ReadOnly Property DisplayName As String
            Get
                Return "Industry Criteria"
            End Get
        End Property

        Public Overrides ReadOnly Property CriteriaName As String
            Get
                Return "Industry"
            End Get
        End Property

        Public Overrides ReadOnly Property CriteriaGroup As StockScreenerCriteriaGroup
            Get
                Return StockScreenerCriteriaGroup.Descriptive
            End Get
        End Property
        Public Overrides ReadOnly Property ProvidedQuoteProperties As QuoteProperty()
            Get
                Return {QuoteProperty.Symbol, _
                        QuoteProperty.Name, _
                        QuoteProperty.LastTradePriceOnly, _
                        QuoteProperty.LastTradeTime, _
                        QuoteProperty.MarketCapitalization}
            End Get
        End Property
        Public Overrides ReadOnly Property ProvidedScreenerProperties As StockScreenerProperty()
            Get
                Return {StockScreenerProperty.ReturnOnEquity, _
                        StockScreenerProperty.ReturnOnAssets, _
                        StockScreenerProperty.ForwardPriceToEarningsRatio}
            End Get
        End Property

        Friend Overrides ReadOnly Property IsValid As Boolean
            Get
                Dim i As Integer = 0
                Return MyBase.IsValid AndAlso Integer.TryParse(MyBase.Value, i) AndAlso (i >= 1 And i <= 9)
            End Get
        End Property

        Public Property Industry As Nullable(Of Industry)
            Get
                If Me.IsValid Then : Return CType(CInt(MyBase.Value), Industry)
                Else : Return Nothing
                End If
            End Get
            Set(ByVal value As Nullable(Of Industry))
                If value.HasValue Then : MyBase.Value = CInt(value).ToString
                Else : MyBase.Value = String.Empty
                End If
            End Set
        End Property

        Public Sub New()
            MyBase.new("d"c)
        End Sub

    End Class

    ''' <summary>
    ''' Criteria definition for number of employees
    ''' </summary>
    ''' <remarks></remarks>
    Public Class NumberOfEmployeesCriteria
        Inherits StockDigitCriteriaDefinition

        Public Overrides ReadOnly Property DisplayName As String
            Get
                Return "Number of Employees Criteria"
            End Get
        End Property

        Public Overrides ReadOnly Property CriteriaName As String
            Get
                Return "Number of Employees"
            End Get
        End Property

        Public Overrides ReadOnly Property ProvidedQuoteProperties As QuoteProperty()
            Get
                Return {QuoteProperty.Symbol, _
                        QuoteProperty.Name, _
                        QuoteProperty.LastTradePriceOnly, _
                        QuoteProperty.LastTradeTime, _
                        QuoteProperty.MarketCapitalization}
            End Get
        End Property
        Public Overrides ReadOnly Property ProvidedScreenerProperties As StockScreenerProperty()
            Get
                Return {StockScreenerProperty.ReturnOnEquity, _
                        StockScreenerProperty.ReturnOnAssets, _
                        StockScreenerProperty.ForwardPriceToEarningsRatio, _
                        StockScreenerProperty.NumberOfEmployees}
            End Get
        End Property

        Public Overrides ReadOnly Property CriteriaGroup As StockScreenerCriteriaGroup
            Get
                Return StockScreenerCriteriaGroup.Descriptive
            End Get
        End Property

        Public Sub New()
            MyBase.New("9o")
        End Sub

    End Class

End Namespace